<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 因为jquery文件 -->
<script type="text/javascript" src="/jquery-3.3.1.min.js"></script>
<script type="text/javascript">

</script>
<title>员工信息</title>
</head>
<body>

  <!-- 添加一个表单将post请求转换成delete请求 
   name必须是_method
   value必须是DELETE名字不能被修改
  -->
  </form>

	<c:if test="${ empty employees }">
		没有员工信息
	</c:if>
    <c:if test="${ !empty employees }">
    		<table border="1" bordercolor="black" cellspacing="0">
    			<tr>
    				<td width="40px">id</td>
    				<td width="30px">name</td>
    				<td width="80px">email</td>
    				<td width="30px">sex</td>
    				<td width="30px">department</td>
    				<td width="40px">编辑</td>
    				<td width="40px">删除</td>
    			</tr>
		    	<c:forEach items="${employees }" var="emp">
		    		<tr>
		    			<td>${emp.id }</tdemployees>
		    			<td>${emp.name }</td>
		    			<td>${emp.email }</td>
		    			<td>${emp.sex == 0 ? '男' : '女'}</td>
		    			<td>${emp.department.name}</td>
		    			<td><a href="${pageContext.request.contextPath}/edit/${emp.id }">Edit</a></td>
		    		    <td><form action="${pageContext.request.contextPath}/delete/${emp.id }" method="post">
		    					<input type="hidden" name="_method" value="DELETE">
		    					<input type="submit" value="Delete">
		    				</form>
		    			</td>
		    		</tr>
		    	</c:forEach>
    		</table>
    </c:if>
    <br><br>
    
</body>
</html>